﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Big_Data;
using Big_Data.View;

namespace Big_Data
{
    public partial class Administrator_Login : Form
    {
        DataBase userDB = new DataBase();
        public Administrator_Login()
        {
            InitializeComponent();
        }



        private void Form2_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" & textBox2.Text != "")
            {
                SqlDataReader temdr = userDB.getsdr("select * from S_administrator where Adm_name='" + textBox1.Text.Trim() + "' and Adm_pwd='" + textBox2.Text.Trim() + "'");
                bool ifcom = temdr.Read();
                if (ifcom)
                {
                    FrmMain 管理员登录成功界面 = new FrmMain();
                    this.Visible = false;
                    管理员登录成功界面.ShowDialog();//此处不可用Show()
                    this.Dispose();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("用户名或密码错误！");
                    textBox1.Text = "";
                    textBox2.Text = "";
                }
                userDB.conn_close();
            }
            else
                MessageBox.Show("请填写用户名和密码！");
        }
    }
}
